#ifndef HASH_TABLE_HH
#define HASH_TABLE_HH 1

#include "list.hh"

//CLICK_DECLS

namespace SNCoding
{

/*2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97 */
#define TABLESIZE 31

template <typename T>
class SimpleHashTable {
public:
	SimpleHashTable():_size(0){
		_table=new List<T>*[TABLESIZE];
		for(unsigned i=0;i<TABLESIZE;i++)
			_table[i]=new List<T>;
	}
	~SimpleHashTable(){
		for(unsigned i=0;i<TABLESIZE;i++)
			delete _table[i];
		delete [] _table;
	}
	bool insert(const T& key){
		//if(erase(key)) _size--;
		_table[hash(key)]->push_back(key);
		_size++;
		return true;
	}
	bool erase(const T& key){
		if(_table[hash(key)]->erase(key)){
			_size--;
			return true;
		}
		else return false;
	}
	bool find(const T& key) const {
		return _table[hash(key)]->find(key)!=_table[hash(key)]->end();
	}
	unsigned size(){
		return _size;
	}
protected:
	unsigned hash(const T& key) const {
		return key % TABLESIZE;
	}
	List<T>** _table;
	unsigned _size;
//	unsigned _cap;
};

}
//CLICK_ENDDECLS

#endif
